var web3 = require('./getWeb3');
var BigNumber = require('bignumber.js');
var Tx = require('ethereumjs-tx').Transaction;


var privateKey = Buffer.from('c3c8d3e65a01265592843eb0126ab1867256ade6d3323da38434ac50a33d38e4', 'hex');

var rawTx = {
  nonce: '0x00',
  gasPrice: web3.utils.toHex(web3.utils.toWei('20','gwei')),
  gasLimit: web3.utils.toHex('10'),
  from: '0xe88699891f17db7395e1346B7645987035B06BCC',
  to: '0x0509954093d415E3E4c2C9DD613861B2EffD8961',
  value: '0x00',
}

var tx = new Tx(rawTx, {'chain':'ropsten'});
tx.sign(privateKey);

var serializedTx = tx.serialize();

 // web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
 // .on('receipt', console.log);

web3.eth.getGasPrice().then(console.log);//获取当前gas价格

 web3.eth.getBalance("0xe88699891f17db7395e1346B7645987035B06BCC")
 .then(console.log); //获取余额

web3.eth.getTransaction('0xf72385e9c13e7ddc62e74d0cc218e16b9cdacb84108cb12d38da0ffdb5c1cf3b')
.then(console.log);//查询指定交易


var receipt = web3.eth.getTransactionReceipt('0xf72385e9c13e7ddc62e74d0cc218e16b9cdacb84108cb12d38da0ffdb5c1cf3b')
.then(console.log);//返回指定交易的收据，使用哈希指定交易。需要指出的是，挂起的交易其收据无效。



